<html>
	<head>
		<title>Revendications conseil de classe</title>
		<g:javascript library="prototype"/>
		<meta name="layout" content="main" />
	</head>
	<body>
	 <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
           
     </div>
		<g:if test="${flash.message}">
			<div class="flash">
				${flash.message}
			</div>
		</g:if>
		
		<div id="pageBody">
		<g:if test="${session.user}">
			Welcome ${session.user.login}
			<br/>
			<g:link action="logout">
	       		logout
	       	</g:link>
	       	<br/>
	       	<g:each in="${userposts}" var="post">
   				<ul>
   					<li>
   						${post.content}
   					</li>
   				</ul>
            </g:each>
		</g:if>
		<g:else>
		Enter your login:
	           <g:form action="loginOrRegister" method="post">
	       	<table border="0">
	       		<tr>
	       			<td>
	       				 Login
	       			</td>
	       			<td>
	       				<input type="text" id="login" name="login" value='${user?.login}'></input>
	       			</td>
	       		</tr>
	       		<tr>
	       			<td>
	       				Password
	       			</td>
	       			<td>
	       				 <input type="password" id="password" name='password' value='${user?.password}'></input>
	       			</td>
	       		</tr>
	       		<tr>
	       			<td colspan="2">
	       				<g:if test="${params.badlogin}">
						    <FONT COLOR="red">Bad login or password</FONT>
						</g:if>
	       			</td>
	       		</tr>
	       		<tr>
	       			<td>
	        			<g:submitButton name="loginButton" value="Login"/>
	       			</td>
	       			<td>
	       				
	       				<g:submitButton name="register" value="Register"/>
	       			</td>
	       		</tr>
	       	</table>
		 </g:form>
		</g:else>
		<br/>
		Tous les posts
		<g:each in="${posts}" var="post">
   				<ul>
   					<li>
   						${post.content} 
   						<label id="likeLab${post.id}">
   						 ${post.likes}
   						</label>
  
   						<g:remoteLink action="like" update="likeLab${post.id}" controller="post" id="${post.id}">
				            +
				        </g:remoteLink>
   					</li>
   				</ul>
            </g:each>
         <br/>
         Tous les inscrits
         <g:each in="${users}" var="user">
         	 <ul>
				<li>
					<g:link controller="user" action="showPosts" id="${user.id}">
       						${user.login}
       				</g:link>
				</li>
   			</ul>
         </g:each>
		</div>
	</body>
</html>